/*
 * Copyright 2015 Red Hat, Inc. and/or its affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

package compiler.impl.p3;

import compiler.impl.p0.AccumulateHandler;
import compiler.impl.p0.AccumulateHelperHandler;
import compiler.impl.p0.AndHandler;
import compiler.impl.p0.CollectHandler;
import compiler.impl.p0.EvalHandler;
import compiler.impl.p0.ExistsHandler;
import compiler.impl.p0.ExprConstraintHandler;
import compiler.impl.p0.ExpressionHandler;
import compiler.impl.p0.FieldBindingHandler;
import compiler.impl.p0.FieldConstraintHandler;
import compiler.impl.p0.ForallHandler;
import compiler.impl.p0.FromHandler;
import compiler.impl.p0.FunctionHandler;
import compiler.impl.p0.LiteralRestrictionHandler;
import compiler.impl.p0.NotHandler;
import compiler.impl.p0.OrHandler;
import compiler.impl.p0.PackageHandler;
import compiler.impl.p0.PatternHandler;
import compiler.impl.p0.PredicateHandler;
import compiler.impl.p0.QualifiedIdentifierRestrictionHandler;
import compiler.impl.p0.QueryHandler;
import compiler.impl.p0.RestrictionConnectiveHandler;
import compiler.impl.p0.ReturnValueRestrictionHandler;
import compiler.impl.p0.RuleHandler;
import compiler.impl.p0.VariableRestrictionsHandler;
import core.api.a1.SemanticModule;
import core.impl.p8.DefaultSemanticModule;

public class RulesSemanticModule extends DefaultSemanticModule
    implements
        SemanticModule {
    public RulesSemanticModule(String url) {
        super( url );

        addHandler( "package",
                    new PackageHandler() );
        addHandler( "rule",
                    new RuleHandler() );
        addHandler( "query",
                    new QueryHandler() );
        addHandler( "attribute",
                    null );
        addHandler( "function",
                    new FunctionHandler() );

        // Conditional Elements
        addHandler( "lhs",
                    new AndHandler() );

        addHandler( "and-restriction-connective",
                    new RestrictionConnectiveHandler() );

        addHandler( "or-restriction-connective",
                    new RestrictionConnectiveHandler() );
        

        addHandler( "and-constraint-connective",
                    new RestrictionConnectiveHandler() );
        addHandler( "or-constraint-connective",
                    new RestrictionConnectiveHandler() );        

        addHandler( "and-conditional-element",
                    new AndHandler() );

        addHandler( "or-conditional-element",
                    new OrHandler() );


        addHandler( "not",
                    new NotHandler() );
        addHandler( "exists",
                    new ExistsHandler() );
        addHandler( "eval",
                    new EvalHandler() );
        addHandler( "pattern",
                    new PatternHandler() );

        addHandler( "from",
                    new FromHandler() );
        addHandler( "forall",
                    new ForallHandler() );
        addHandler( "collect",
                    new CollectHandler() );
        addHandler( "accumulate",
                    new AccumulateHandler() );

        // Field Constraints
        addHandler( "expr",
                    new ExprConstraintHandler() );
        addHandler( "field-constraint",
                    new FieldConstraintHandler() );
        addHandler( "literal-restriction",
                    new LiteralRestrictionHandler() );
        addHandler( "variable-restriction",
                    new VariableRestrictionsHandler() );
        addHandler( "predicate",
                    new PredicateHandler() );

        addHandler( "return-value-restriction",
                    new ReturnValueRestrictionHandler() );
        addHandler( "qualified-identifier-restriction",
                    new QualifiedIdentifierRestrictionHandler() );

        addHandler( "field-binding",
                    new FieldBindingHandler() );

        addHandler( "field-binding",
                    new FieldBindingHandler() );

        addHandler( "init",
                    new AccumulateHelperHandler() );
        addHandler( "action",
                    new AccumulateHelperHandler() );
        addHandler( "result",
                    new AccumulateHelperHandler() );
        addHandler( "reverse",
                    new AccumulateHelperHandler() );

        addHandler( "external-function",
                    new AccumulateHelperHandler() );

        addHandler( "expression",
                    new ExpressionHandler() );
    }
}
